package com.googlecode.lookie.imagedb.internal;

import org.springframework.jdbc.datasource.SingleConnectionDataSource;

/*
 * <p> Extends SingleConnectionDataSource to prevent the connection from being closed when the bean
 * is destroyed by the application context. </p>
 */
public class ExtendedSingleConnectionDataSource
    extends SingleConnectionDataSource
{

    private boolean closeOnDestroy = false;

    public boolean isCloseOnDestroy()
    {
        return closeOnDestroy;
    }

    public void setCloseOnDestroy( boolean closeOnDestroy )
    {
        this.closeOnDestroy = closeOnDestroy;
    }

    public void destroy()
    {
        if ( closeOnDestroy )
        {
            super.destroy();
        }
    }

}
